package controller;

import java.io.IOException;

import listener.ListenerContainer;
import listener.Sender;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class MyController {
	@Autowired
	ListenerContainer listenconteContainer;
	@Autowired
	Sender sender;

	@RequestMapping(value = "hello", method = RequestMethod.GET)
	public String goToForm() {
		return "MyJSP";
	}

	@RequestMapping(value = "submit", method = RequestMethod.POST)
	public String getValue(@RequestParam("myvalue") String myvalue)
			throws IOException, InterruptedException {

		sender.getaTemplate().convertAndSend("testMessage", myvalue);

		System.out.println("Sending message...");
		return "MyJSP";
	}

}
